import MD5 from './MD5.js';
// 支付
export default function (data) {
    return new Promise((resolve, reject) => {
        var paySign =
            "appId=" + data.appId +
            "&nonceStr=" + data.nonceStr +
            "&package=prepay_id=" + data.prepayId +
            "&signType=MD5&timeStamp=" + data.timeStamp +
            "&key=8b3ee2a553094776b82d89176c3972af";
        paySign = MD5(paySign).toUpperCase();
        var obj = {
            ...data,
            package: `prepay_id=${data.prepayId}`,
            paySign,
            signType: 'MD5',
            timeStamp: data.timeStamp.toString(),
            // timeStamp: (+new Date).toString().substr(0, 10),
            success: resolve,
            fail: reject,
        }
        wx.requestPayment(obj)
    })
}